package top.biangege.bbs.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Result implements Serializable {

    private Integer code;

    private Object data;

    private String message;

    public Result(Integer code, Object data) {
        this.code = code;
        this.data = data;
    }

    public static Result success() {
        return new Result(200, null);
    }

    public static Result success(Object data) {
        return new Result(200, data);
    }

    public static Result error() {
        return new Result(500, null, "error");
    }

    public static Result error(String message){
        return new Result(500, null, message);
    }
}
